package es.ubu.interfaz;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.text.ParseException;

import javax.swing.JFormattedTextField;
import javax.swing.JFormattedTextField.AbstractFormatter;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.text.MaskFormatter;

import es.ubu.mascaras.emailVerifier;


public class ContactoCompleto extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 879123317526829298L;
	private JTextField textFieldNombre;
	private JTextField textFieldApellido;
	private JTextField textFieldProvincia;
	private JTextField textFieldCodPos;
	private JTextField textFieldTelefono;
	private JTextField textFieldEmail;

	/**
	 * Create the panel.
	 */
	public ContactoCompleto() {
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{62, 266, 0, 0};
		gridBagLayout.rowHeights = new int[]{20, 20, 20, 14, 0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 1.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		JLabel Identificador = new JLabel("Identificador");
		GridBagConstraints gbc_Identificador = new GridBagConstraints();
		gbc_Identificador.anchor = GridBagConstraints.WEST;
		gbc_Identificador.insets = new Insets(0, 0, 5, 5);
		gbc_Identificador.gridx = 0;
		gbc_Identificador.gridy = 0;
		add(Identificador, gbc_Identificador);
		
		JSpinner spinner = new JSpinner();
		spinner.setAlignmentX(Component.RIGHT_ALIGNMENT);
		GridBagConstraints gbc_spinner = new GridBagConstraints();
		gbc_spinner.anchor = GridBagConstraints.NORTHWEST;
		gbc_spinner.insets = new Insets(0, 0, 5, 5);
		gbc_spinner.gridx = 1;
		gbc_spinner.gridy = 0;
		add(spinner, gbc_spinner);
		
		JLabel lblNombre = new JLabel("Nombre");
		GridBagConstraints gbc_lblNombre = new GridBagConstraints();
		gbc_lblNombre.anchor = GridBagConstraints.EAST;
		gbc_lblNombre.insets = new Insets(0, 0, 5, 5);
		gbc_lblNombre.gridx = 0;
		gbc_lblNombre.gridy = 1;
		add(lblNombre, gbc_lblNombre);
		
		textFieldNombre = new JTextField();
		textFieldNombre.setColumns(10);
		GridBagConstraints gbc_textFieldNombre = new GridBagConstraints();
		gbc_textFieldNombre.fill = GridBagConstraints.HORIZONTAL;
		gbc_textFieldNombre.insets = new Insets(0, 0, 5, 5);
		gbc_textFieldNombre.gridx = 1;
		gbc_textFieldNombre.gridy = 1;
		add(textFieldNombre, gbc_textFieldNombre);
		
		JLabel lblNewLabel_1 = new JLabel("Direcci\u00F3n");
		GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
		gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel_1.gridx = 0;
		gbc_lblNewLabel_1.gridy = 2;
		add(lblNewLabel_1, gbc_lblNewLabel_1);
		
		textFieldApellido = new JTextField();
		textFieldApellido.setColumns(10);
		GridBagConstraints gbc_textFieldApellido = new GridBagConstraints();
		gbc_textFieldApellido.fill = GridBagConstraints.HORIZONTAL;
		gbc_textFieldApellido.insets = new Insets(0, 0, 5, 5);
		gbc_textFieldApellido.gridx = 1;
		gbc_textFieldApellido.gridy = 2;
		add(textFieldApellido, gbc_textFieldApellido);
		
		JLabel lblNewLabel = new JLabel("Cargo");
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridx = 0;
		gbc_lblNewLabel.gridy = 3;
		add(lblNewLabel, gbc_lblNewLabel);
		
				
		textFieldProvincia = new JTextField();
		GridBagConstraints gbc_textFieldProvincia = new GridBagConstraints();
		gbc_textFieldProvincia.fill = GridBagConstraints.HORIZONTAL;
		gbc_textFieldProvincia.insets = new Insets(0, 0, 5, 5);
		gbc_textFieldProvincia.gridx = 1;
		gbc_textFieldProvincia.gridy = 3;
		add(textFieldProvincia, gbc_textFieldProvincia);
		textFieldProvincia.setColumns(10);
		
		
		MaskFormatter mascaraCP = null;
		try {
			mascaraCP = new MaskFormatter("#####");
		} catch (ParseException e) {
			e.printStackTrace();
		}
		mascaraCP.setPlaceholderCharacter('0');
		
		JLabel lblTelfono = new JLabel("Tel\u00E9fono");
		GridBagConstraints gbc_lblTelfono = new GridBagConstraints();
		gbc_lblTelfono.anchor = GridBagConstraints.EAST;
		gbc_lblTelfono.insets = new Insets(0, 0, 5, 5);
		gbc_lblTelfono.gridx = 0;
		gbc_lblTelfono.gridy = 4;
		add(lblTelfono, gbc_lblTelfono);
		
		MaskFormatter mascaraTelefono = null;
		try {
			mascaraTelefono = new MaskFormatter("(34)###-###-###");
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		mascaraTelefono.setPlaceholderCharacter('0');
		textFieldTelefono = new JFormattedTextField(mascaraTelefono);
		textFieldTelefono.setText("(34) 000-000-000");
		GridBagConstraints gbc_textFieldTelefono = new GridBagConstraints();
		gbc_textFieldTelefono.gridwidth = 2;
		gbc_textFieldTelefono.anchor = GridBagConstraints.WEST;
		gbc_textFieldTelefono.insets = new Insets(0, 0, 5, 0);
		gbc_textFieldTelefono.gridx = 1;
		gbc_textFieldTelefono.gridy = 4;
		add(textFieldTelefono, gbc_textFieldTelefono);
		textFieldTelefono.setColumns(10);
		
		JLabel lblExtensin = new JLabel("Extensi\u00F3n");
		GridBagConstraints gbc_lblExtensin = new GridBagConstraints();
		gbc_lblExtensin.anchor = GridBagConstraints.EAST;
		gbc_lblExtensin.insets = new Insets(0, 0, 5, 5);
		gbc_lblExtensin.gridx = 0;
		gbc_lblExtensin.gridy = 5;
		add(lblExtensin, gbc_lblExtensin);
		
		JFormattedTextField formattedTextField = new JFormattedTextField((AbstractFormatter) null);
		formattedTextField.setColumns(10);
		GridBagConstraints gbc_formattedTextField = new GridBagConstraints();
		gbc_formattedTextField.anchor = GridBagConstraints.WEST;
		gbc_formattedTextField.insets = new Insets(0, 0, 5, 5);
		gbc_formattedTextField.gridx = 1;
		gbc_formattedTextField.gridy = 5;
		add(formattedTextField, gbc_formattedTextField);
		
		JLabel lblCdigoPostal = new JLabel("Fax");
		GridBagConstraints gbc_lblCdigoPostal = new GridBagConstraints();
		gbc_lblCdigoPostal.fill = GridBagConstraints.VERTICAL;
		gbc_lblCdigoPostal.anchor = GridBagConstraints.EAST;
		gbc_lblCdigoPostal.insets = new Insets(0, 0, 5, 5);
		gbc_lblCdigoPostal.gridx = 0;
		gbc_lblCdigoPostal.gridy = 6;
		add(lblCdigoPostal, gbc_lblCdigoPostal);
		textFieldCodPos =new JFormattedTextField(mascaraCP);		
		textFieldCodPos.setColumns(10);
		GridBagConstraints gbc_textFieldCodPos = new GridBagConstraints();
		gbc_textFieldCodPos.insets = new Insets(0, 0, 5, 5);
		gbc_textFieldCodPos.anchor = GridBagConstraints.WEST;
		gbc_textFieldCodPos.gridx = 1;
		gbc_textFieldCodPos.gridy = 6;
		add(textFieldCodPos, gbc_textFieldCodPos);
		
		JLabel lblEmail = new JLabel("Email");
		GridBagConstraints gbc_lblEmail = new GridBagConstraints();
		gbc_lblEmail.anchor = GridBagConstraints.EAST;
		gbc_lblEmail.insets = new Insets(0, 0, 5, 5);
		gbc_lblEmail.gridx = 0;
		gbc_lblEmail.gridy = 7;
		add(lblEmail, gbc_lblEmail);
		
		textFieldEmail = new JFormattedTextField();
		textFieldEmail.setInputVerifier(new emailVerifier());
		GridBagConstraints gbc_textFieldEmail = new GridBagConstraints();
		gbc_textFieldEmail.insets = new Insets(0, 0, 5, 5);
		gbc_textFieldEmail.fill = GridBagConstraints.HORIZONTAL;
		gbc_textFieldEmail.gridx = 1;
		gbc_textFieldEmail.gridy = 7;
		add(textFieldEmail, gbc_textFieldEmail);
		textFieldEmail.setColumns(10);

	}
}
